package com.ludomancy.insane;

import java.awt.Point;

import com.ludomancy.gamelib.MathHelper;
import com.ludomancy.gamelib.entity.Entity;

public class InsaneEntity extends Entity
{
	public InsaneEntity(Point pos)
	{
		super(pos);
	}
	
	public boolean isPickable()
	{
		return false;
	}
	
	public void apply(Point pos)
	{
	}
	
	public Point getNextPos(Point to, int speed)
	{
		float dirX = to.x - pos.x;
		float dirY = to.y - pos.y;
		if(MathHelper.dist(0, 0, dirX, dirY) < speed)
		{
			return new Point(to.x, to.y);
		}
		else
		{
			float[] norm = MathHelper.normalize(dirX, dirY, new float[2]);
			dirX = norm[0];
			dirY = norm[1];
			dirX *= speed;
			dirY *= speed;
			return new Point(pos.x + (int)dirX, pos.y + (int)dirY);
		}
	}
	
	public int getWidth()
	{
		return (int)parent.projector.screenToWorldX(8);
	}
	
	public int getHeight()
	{
		return (int)parent.projector.screenToWorldY(8);
	}
	
	public Point toTile(Point position)
	{
		return Game.game.earth.toTile(parent.projector.worldToScreen(position));
	}
	
	public Point toTile()
	{
		return Game.game.earth.toTile(parent.projector.worldToScreen(pos));
	}
}
